<template>
	<view class="all">
		<view class="block">
			<view class="cards">
				<view class="cards_left">到账{{typeNa}}</view>
				<view class="cards_right">
					<view class="r_top">{{cardnumber}}</view>
					<view class="smalls">2小时内到账</view>
				</view>
			</view>
			<view class="title">
				提现金额<text class="smalls">(必须大于100元，手续费5%)</text>
			</view>
			<view class="contents">
				<view>￥</view>
				<input v-model="cnumner" type="number"/>
			</view>
			<view class="smalls">当前零钱余额 {{balance}} 元，<text class="blues" @click.stop="quti">全部提现</text></view>
			<view class="btn " :class="cnumner!='' && cnumner!=0?'reds':''" @click="tixian">提现</view>
			<view class="smallt">1·提现次数：为便于高效结算，每个账户每周限提一次</view>
			<view class="smallt">2·提现申请时间：每周一至周五</view>
			<view class="smallt">3·提现到账时间​：三个工作日以内</view>
			<view class="smallt">​4·起提金额：100元起提</view>
			<view class="smallt">​5·提现需扣除相应的费率</view>
			<view class="smallt">​特别提醒：提现需要完成账户实名认证且绑定的银行卡持有人必须与账户实名认证信息一致，否则提现将会失败。
（特别提醒，关于第四点100元起提是100元以上可以全部提走，不是100元的整数倍。</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cardnumber: '', //卡号
				balance: 0, //余额
				cnumner:'',  //充值金额
				type: '', //类型
				typeNa : '' //名称
			};
		},
		onLoad(options) {
			let obj = JSON.parse(options.item);
			if(obj.typeid == 0){
				this.type = 0;
				this.typeNa = '银行卡';
				let cardh = obj.bank_number;
				this.cardnumber = cardh.substring(0, cardh.length - 8) + '****' + cardh.substring(cardh.length - 4);
			}else if(obj.typeid == 1){
				this.type = 1;
				this.typeNa = '支付宝';
			}else if(obj.typeid == 2){
				this.type = 2;
				this.typeNa = '微信';
			}
			this.balance = obj.money;
		},
		methods:{
			//全部提现
			quti(){
				this.cnumner = this.balance;
			},
			tixian(){
				if(this.cnumner!=0){
					if(this.cnumner < 100){
						this.$api.msg("提现金额必须大于100元")
						return false;
					}
					// if(this.cnumner % 100 != 0){
					// 	this.$api.msg('金额必须是100的整数倍');
					// 	return false;
					// }
					this.$http.post('withdrawaldo', {num : this.cnumner, type: this.type}).then(res => {
						this.$api.msg(res.msg);
						if(res.code == 1){
							setTimeout(() => {
								uni.switchTab({
									url: '/pages/user/user'
								})
							}, 800)
						}
					})
				}
			}
		},
	}
</script>

<style lang="scss">
	page{
		height: 100%;
		width: 100%;
		background: #EDEDED;
		font-size: 32upx;
	}
	.all{
		padding: 30upx;
	}
	.block{
		background:#FFFFFF;
		padding-bottom:30upx;
		.title{
			width: 100%;
			font-size: 34upx;
			padding: 20upx;
		}
	}
	.contents,.cards{
		display: flex;
		justify-content: space-between;
	}
	.contents{
		padding: 20upx;
		position: relative;
		height: 120upx;
		font-size: 60upx;
	}
	.contents input{
		width: 90%;
		position: absolute;
		border-bottom: 1px solid #F3F3F3;
		bottom: 0;
		text-indent: 5upx;
		text-align: center;
		font-size: 60upx;
	}
	.smalls{
		color: gray;
		font-size: 25upx;
		padding: 20upx;
	}
	.smallt{
		color: gray;
		font-size: 12px;
		padding: 3upx;
	}
	.cards{
		padding: 20upx;
		background: #FBFBFB;
	}
	.cards_right{
		width: 66%;
	}
	.blues{
		color: #596E94;
	}
	.btn{
		margin: 20upx auto;
		padding: 25upx 0;
		width: 90%;
		text-align: center;
		background: #F2F2F2;
		color: gray;
		border-radius: 5upx;
	}
	.reds{
		background: #FF4936;
		color: #FFFFFF;
	}
</style>
